package com.linsen.erp.admin.provider.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

//数据权限类型
@Getter
@AllArgsConstructor
public enum DataScopeTypeEnum {

    SELF(1,"仅限个人"),
    ALL(2,"查看全部"),
    DEPT(3,"仅限当前部门"),
    DEPT_FETCH(4,"当前部门及子部门"),
    CUSTOMIZE(5,"自定义范围"),
    ;

    @JsonValue
    private final Integer value;
    private final String desc;

    private static final Map<Integer, DataScopeTypeEnum> VALUES = new HashMap<>();

    static {
        for (final DataScopeTypeEnum dataScopeTypeEnum : DataScopeTypeEnum.values()) {
            DataScopeTypeEnum.VALUES.put(dataScopeTypeEnum.getValue(), dataScopeTypeEnum);
        }
    }

    @JsonCreator
    public static DataScopeTypeEnum getByValue(Integer value) {
        return DataScopeTypeEnum.VALUES.get(value);
    }
}
